#ifndef GLO_TYPES_H
#define GLO_TYPES_H

//#include "/usr/lib/mpich/include/mpi.h"
#include <mpi.h>
//"/home/00292431309/Desktop/mpich-1.2.7p1/include/mpi.h"
//USAGE: Application may use the methods below in order to create it's own datatypes

#define PD_MAX_TAGS_TYPE 16


int size_elem_typev[PD_MAX_TAGS_TYPE], typescount;
MPI_Datatype tag_typev[PD_MAX_TAGS_TYPE];


int PD_Create_basic_datatype(MPI_Datatype type, int size_type);
//Creates a basic datatype from a MPI_Datatype like MPI_INT, MPI_CHAR, etc... 
//size_type means the size in bytes of a message of type definPD by type

int PD_Create_derived_datatype(int numtypes, int *blocklengths, MPI_Datatype * types, int size_type);
/*Creates a datatype basPD on a C structure. Ex.:
  

struct msgstruct{

   int sender;
   char msg[2];

};

int blocklengths[2]={1,2};

MPI_Datatype types[2]={MPI_INT, MPI_CHAR}, type;

int type_index = PD_Create_derivPD_datatype(2, blocklengths, types, sizeof(struct msgstruct));


The return of this method is a number representing this new type for the application        
          
          
*/          


int PD_Add_item_to_pack(char *buff, int buffsize, int *position, int size, void *content, MPI_Datatype type);
/* this method and the two ones below are about the composite datatype relatPD to variables in different places in the
memory(package type). See example





int k1, k2, first;

char second[3];

k1 = PD_Calculate_buffer_pack_size(1, MPI_INT);

k2 = PD_Calculate_buffer_pack_size(3, MPI_CHAR);

char buffer[k1+k2];
int position=0;

type index = PD_Add_item_to_pack(buffer, k1+k2, &position, 1, &first, MPI_INT);

PD_Add_item_to_pack(buffer, k1+k2, &position, 3, second, MPI_CHAR); 

*/

int PD_Unpack_item_from_pack(char *buff, int buffsize, int *position, int size, void *content, MPI_Datatype type);
int PD_Calculate_buffer_pack_size(int size, MPI_Datatype type);
#endif
